package com.nbsaas.boot.lock;

import com.nbsaas.boot.lock.api.LockService;
import com.nbsaas.boot.lock.impl.ReentrantLockCountingService;

import java.util.concurrent.*;
import java.util.concurrent.locks.*;

public class LockManager {

    // 单例模式，保证LockManager只有一个实例
    private static volatile ReentrantLockCountingService instance;

    // 私有化构造方法，确保外部不能直接实例化
    private LockManager() {
    }

    public static ReentrantLockCountingService getLockService(){
        if (instance == null) {
            synchronized (LockManager.class) {
                if (instance == null) {
                    instance = new ReentrantLockCountingService();
                }
            }
        }
        return instance;
    }

}
